package com.wc.alorithm_blue_bridge._搜索与图论.路径之谜;

import java.io.*;

/**
 * @Author congege
 * @Description 路径之谜
 * https://www.lanqiao.cn/problems/89/learning/?page=1&first_category_id=1
 * @Date Created in 2023/12/12-10:07
 */
public class Main {
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    static int n;
    static boolean[][] vis = new boolean[20][20];
    static int[] cntX = new int[20];
    static int[] cntY = new int[20];
    static int[] ans = new int[20 * 20];
    static int step;
    static boolean success;
    static int[] positionX = new int[]{0, 1, 0, -1};
    static int[] positionY = new int[]{1, 0, -1, 0};

    public static void main(String[] args) {
        n = nextInt();
        for (int i = 0; i < n; i++) {
            cntY[i] = nextInt();
        }
        for (int i = 0; i < n; i++) {
            cntX[i] = nextInt();
        }
        dfs(0, 0, 0);
        printAns();
    }

    public static void dfs(int x, int y, int step) {
        // 记录
        ans[step] = x * n + y;
        // 标记
        vis[x][y] = true;
        // 射箭
        cntX[x]--;
        cntY[y]--;

        if (x == n - 1 && y == n - 1 && isSuccess()) {
            // 成功了
            success = true;
            Main.step = step;
            return;
        }
        int nextX, nextY;
        for (int i = 0; i < 4; i++) {
            nextX = x + positionX[i];
            nextY = y + positionY[i];
            if (!success && !isBorder(nextX, nextY) && !vis[nextX][nextY]) {
                // 这步骤可以剪枝很多
                if (cntX[nextX] > 0 && cntY[nextY] > 0) {
                    dfs(nextX, nextY, step + 1);
                    vis[nextX][nextY] = false;
                    cntX[nextX]++;
                    cntY[nextY]++;
                }
            }
        }
    }

    public static void printAns() {
        StringBuffer sb = new StringBuffer();
        sb.append(ans[0]);
        for (int i = 1; i <= step; i++) {
            sb.append(' ');
            sb.append(ans[i]);
        }
        out.println(sb);
        out.flush();
    }

    public static boolean isSuccess() {
        for (int i = 0; i < n; i++) {
            if (cntX[i] != 0 || cntY[i] != 0) {
                return false;
            }
        }
        return true;
    }

    public static boolean isBorder(int x, int y) {
        return x < 0 || x == n || y < 0 || y == n;
    }

    public static int nextInt() {
        try {
            in.nextToken();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return (int) in.nval;
    }
}
